import os


# 基础配置
class Config:
    # 编码设置
    ENCODING = 'utf-8'

    # 路径配置
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    DEFAULT_WORK_DIR = os.path.join(BASE_DIR, 'videos')
    DEFAULT_M3U8_PATH = os.path.join(BASE_DIR, 'tools', 'N_m3u8DL-CLI_v3.0.2.exe')

    # 请求头配置
    DEFAULT_HEADERS = {
        'accept': 'application/json, text/plain, */*',
        'accept-language': 'zh-CN,zh;q=0.9',
        'cache-control': 'no-cache',
        'content-type': 'application/json;charset=UTF-8',
        'origin': 'https://www.iqihang.com',
        'referer': 'https://www.iqihang.com/ark/exam26?code=11',
        'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.2.11 (KHTML, like Gecko) Version/15.3 Mobile/15P492T Safari/602.10 Edg/149.0.0.0',
    }

    # M3U8请求头
    M3U8_HEADERS = {
        'Host': 'p.bokecc.com',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
        'referer': 'https://www.iqihang.com/',
        'accept-language': 'zh-CN,zh;q=0.9',
    }

    # API端点
    API_ENDPOINTS = {
        'login': 'https://www.iqihang.com/api/ark/sso/login',  # 登录接口
        'course_list': 'https://www.iqihang.com/api/ark/web/v1/user/course/course-list',  # 获取账户下拥有的课程信息并选择需要下载哪个课程包
        'course_catalog': 'https://www.iqihang.com/api/ark/web/v1/course/catalog/',  # 获取产品包含的的视频详细信息，主要需要视频名称和vid
        'player_token': 'https://www.iqihang.com/api/ark/web/v1/baijiayun/player/token',  # 获取mp4下载Token
        'm3u8_url': 'https://p.bokecc.com/servlet/getvideofile',  # 获取m3u8视频下载地址
        'mp4_url': 'https://www.baijiayun.com/vod/video/getPlayUrl',  # 获取mp4视频下载地址
    }

    # 固定参数
    FIXED_PARAMS = {
        'siteid': 'A183AC83A2983CCC',
        'source': '启航教育',
        'sourceType': 17,
        'terminal': 4,
        'loginType': 2,
        'clientType': 2,
        'browser': 'chrome',
        'browserVersion': '131.0.0.0',
        'os': 'Win32',
        'osVersion': 'window 10',
    }

    # 下载配置
    DOWNLOAD_CONFIG = {
        'max_threads': 32,
        'retry_count': 3,
        'chunk_size': 8192,
    }

    # 保存配置
    SAVE_CONFIG = {
        'save_course_info': False,  # 是否保存课程信息，默认不保存
    }

    # 视频质量配置
    VIDEO_QUALITIES = ['1080p', 'superHD']
